<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
session_start();
class Fiche_clinique extends CI_Controller {
	function __construct()
	    {
		parent::__construct();
                $this->load->helper(array('url','form'));
                $this->load->library('form_validation');
                $this->load->library('session');
                $this->load->library('lang');
                $this->load->library('user_agent');
                $this->load->library('input');
                $this->load->library('uri');
                $this->load->model('mod_fiche_clinique');
                $this->load->library('googlemaps');
            }
            function index(){
                if(isset($_SESSION['lg'])) { 
                    $this->load->view('routeur/rt');
                } else {
                if($this->agent->accept_lang('fr')){
                        $_SESSION['lg']='fr';
                        $this->load->view('routeur/rt');
                }elseif ($this->agent->accept_lang('de')) {
                        $_SESSION['lg']='de';
                        $this->load->view('routeur/rt');
                    } else {
                        $_SESSION['lg']='en';
                        $this->load->view('routeur/rt');
                    }
                
                }
            }
            function afficher(){
                //echo " afficher methode !";
                $donne_clinique = array();
                /*Google maps*/
                $config['center'] = '37.4419, -122.1419';
                $config['zoom'] = 'auto';
                $this->googlemaps->initialize($config);

                $marker = array();
                $marker['position'] = '37.429, -122.1519';
                $marker['infowindow_content'] = '1 - Clinic Map!';
                $marker['icon'] = 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|9999FF|000000';
                $this->googlemaps->add_marker($marker);

                $marker = array();
                $marker['position'] = '37.409, -122.1319';
                $marker['draggable'] = TRUE;
                $marker['animation'] = 'DROP';
                $this->googlemaps->add_marker($marker);

                $marker = array();
                $marker['position'] = '37.449, -122.1419';
                $marker['onclick'] = 'alert("You just clicked me!!")';
                $this->googlemaps->add_marker($marker);
                $donne_clinique['map'] = $this->googlemaps->create_map();

                if(isset($_SESSION['lg'])) { 
                    $lg=$_SESSION['lg'];
                    $this->lang->load('header',$lg);
                    $this->lang->load('lien',$lg);
                    $this->lang->load('container',$lg);
                    $this->lang->load('footer',$lg);
                    $this->lang->load('navigbar',$lg);
                    $this->lang->load('tarifs',$lg);
                    /*TRAITEMENT*/
                    $donne_clinique ['pays'] = $this->uri->segment(3,0);
                    $donne_clinique['ville'] = $this->uri->segment(4,0);
                    $nom_url = $this->uri->segment(5,0);
                    $id=$this->mod_fiche_clinique->translateNomUrlId($nom_url);
                    if($id==0){ echo "clinique inexistante";}
                    else {
                    $donne_clinique['info'] = $this->mod_fiche_clinique->getInfoClinicId($id);
                    //$this->load->view('clinic/vue_fiche_clinique',$donne_clinique);
                    $this->load->view('clinic/fiche-clinique',$donne_clinique);
                    }
                    $_SESSION['lg']=$lg;
                } else {
                if($this->agent->accept_lang('fr')){
                        $this->lang->load('header','fr');
                        $this->lang->load('lien','fr');
                        $this->lang->load('container','fr');
                        $this->lang->load('footer','fr');
                        $this->lang->load('navigbar',$lg);
                        $this->lang->load('tarifs',$lg);
                        $_SESSION['lg']='fr';
                        /*TRAITEMENT*/
                        $donne_clinique ['pays'] = $this->uri->segment(3,0);
                        $donne_clinique['ville'] = $this->uri->segment(4,0);
                        $nom_url = $this->uri->segment(5,0);
                        $id=$this->mod_fiche_clinique->translateNomUrlId($nom_url);
                        if($id==0){ echo "clinique inexistante";}
                        else {
                        $donne_clinique['info'] = $this->mod_fiche_clinique->getInfoClinicId($id);
                        $this->load->view('clinic/vue_fiche_clinique',$donne_clinique);
                        }
                }elseif ($this->agent->accept_lang('de')) {
                        $this->lang->load('header','de');
                        $this->lang->load('lien','de');
                        $this->lang->load('container','de');
                        $this->lang->load('footer','de');
                        $this->lang->load('navigbar',$lg);
                        $this->lang->load('tarifs',$lg);
                        $_SESSION['lg']='de';
                        /*TRAITEMENT*/
                        $donne_clinique ['pays'] = $this->uri->segment(3,0);
                        $donne_clinique['ville'] = $this->uri->segment(4,0);
                        $nom_url = $this->uri->segment(5,0);
                        $id=$this->mod_fiche_clinique->translateNomUrlId($nom_url);
                        if($id==0){ echo "clinique inexistante";}
                        else {
                        $donne_clinique['info'] = $this->mod_fiche_clinique->getInfoClinicId($id);
                        $this->load->view('clinic/vue_fiche_clinique',$donne_clinique);
                        }   
                    } else {
                        $this->lang->load('header','en');
                        $this->lang->load('lien','en');
                        $this->lang->load('container','en');
                        $this->lang->load('footer','en');
                        $this->lang->load('navigbar',$lg);
                        $this->lang->load('tarifs',$lg);
                        $_SESSION['lg']='de';
                        /*TRAITEMENT*/
                        $donne_clinique ['pays'] = $this->uri->segment(3,0);
                        $donne_clinique['ville'] = $this->uri->segment(4,0);
                        $nom_url = $this->uri->segment(5,0);
                        $id=$this->mod_fiche_clinique->translateNomUrlId($nom_url);
                        if($id==0){ echo "clinique inexistante";}
                        else {
                        $donne_clinique['info'] = $this->mod_fiche_clinique->getInfoClinicId($id);
                        $this->load->view('clinic/vue_fiche_clinique',$donne_clinique);
                        }
                    }
                
                }
                
            }
            
            function notre_equipe(){
                //echo " notre_equipe method ";
                $donne_clinique = array();
                
                if(isset($_SESSION['lg'])) { 
                    $lg=$_SESSION['lg'];
                }else {
                    if($this->agent->accept_lang('fr')){

                            $lg=$_SESSION['lg']='fr';
                    }elseif ($this->agent->accept_lang('de')) {
                            $lg=$_SESSION['lg']='de';
                        } else {
                            $lg=$_SESSION['lg']='de';
                        }
                }
                
                $this->lang->load('header',$lg);
                $this->lang->load('lien',$lg);
                $this->lang->load('container',$lg);
                $this->lang->load('footer',$lg);
                $this->lang->load('navigbar',$lg);
                $this->lang->load('tarifs',$lg);
                /*TRAITEMENT*/
                $donne_clinique ['pays'] = $this->uri->segment(3,0);
                $donne_clinique['ville'] = $this->uri->segment(4,0);
                $nom_url = $this->uri->segment(5,0);
                $id=$this->mod_fiche_clinique->translateNomUrlId($nom_url);
                if($id==0){ 
                    echo "clinique inexistante 1"."</br>";

                }
                else {
                $donne_clinique['info'] = $this->mod_fiche_clinique->getInfoClinicId($id);
                $donne_clinique['equipe'] = $this->mod_fiche_clinique->getEquipes($id);
                //$this->load->view('clinic/vue_fiche_clinique',$donne_clinique);
                $this->load->view('clinic/v_notre-equipe',$donne_clinique);
                }
                $_SESSION['lg']=$lg;
                
                
            }
            
            function afficher2(){
                        $donne_clinique = array();
                        $donne_clinique['langue']=$this->uri->segment(3,0);
                        $donne_clinique ['pays'] = $this->uri->segment(4,0);
                        $donne_clinique['ville'] = $this->uri->segment(5,0);
                        $nom_url = $this->uri->segment(6,0);
                        echo $this->uri->segment(1,0)."<br />";
                        echo $this->uri->segment(2,0)."<br />";
                        echo "LANGUE :".$donne_clinique['langue']."<br />";
                        echo "PAYS : ".$donne_clinique ['pays']."<br />";
                        echo "VILLE :".$donne_clinique ['ville']."<br />";
                        echo "NOM-URL : ".$nom_url;
                        /*$id=$this->mod_fiche_clinique->translateNomUrlId($nom_url);
                        if($id==0){ echo "clinique inexistante";} else {
                        $donne_clinique['info'] = $this->mod_fiche_clinique->getInfoClinicId($id);
                        $this->load->view('clinic/vue_fiche_clinique',$donne_clinique);
                        }*/
                
            }
            function pays(){
                $lg=$_SESSION['lg'];
                    $this->lang->load('header',$lg);
                    $this->lang->load('lien',$lg);
                    $this->lang->load('container',$lg);
                    $this->lang->load('footer',$lg);
                    $this->load->view('clinic/vue_pays');
                
            }
            function ville(){
                $lg=$_SESSION['lg'];
                    $this->lang->load('header',$lg);
                    $this->lang->load('lien',$lg);
                    $this->lang->load('container',$lg);
                    $this->lang->load('footer',$lg);
                    $this->load->view('clinic/vue_ville');
                
            }
            function la_clinique(){
                $lg=$_SESSION['lg'];
                    $this->lang->load('header',$lg);
                    $this->lang->load('lien',$lg);
                    $this->lang->load('container',$lg);
                    $this->lang->load('footer',$lg);
                    /*TRAITEMENT*/
                    $donne_clinique = array();
                    $donne_clinique ['pays'] = $this->uri->segment(3,0);
                    $donne_clinique['ville'] = $this->uri->segment(4,0);
                    $nom_url = $this->uri->segment(5,0);
                    $id=$this->mod_fiche_clinique->translateNomUrlId($nom_url);
                    if($id==0){ echo "clinique inexistante";}
                    else {
                    $donne_clinique['equipe'] = $this->mod_fiche_clinique->getInfoClinicId($id);
                    $this->load->view('clinic/vue_step_la_clinique',$donne_clinique);
                    }
                
            }
            /*function notre_equipe(){
                    $lg=$_SESSION['lg'];
                    $this->lang->load('header',$lg);
                    $this->lang->load('lien',$lg);
                    $this->lang->load('container',$lg);
                    $this->lang->load('footer',$lg);
                   
                    $donne_clinique = array();
                    $donne_clinique ['pays'] = $this->uri->segment(3,0);
                    $donne_clinique['ville'] = $this->uri->segment(4,0);
                    $nom_url = $this->uri->segment(5,0);
                    $id=$this->mod_fiche_clinique->translateNomUrlId($nom_url);
                    if($id==0){ echo "clinique inexistante";}
                    else {
                    $donne_clinique['equipe'] = $this->mod_fiche_clinique->getNotreEquipeIdClinic($id);
                    $this->load->view('clinic/vue_step_notre_equipe',$donne_clinique);
                    }
            }*/
            
            
            function traitement_et_tarif(){
                $donne_clinique = array();
                if(isset($_SESSION['lg'])) { 
                    $lg=$_SESSION['lg'];
                } else {
                    if($this->agent->accept_lang('fr')){
                            $lg=$_SESSION['lg']='fr';
                    }else if ($this->agent->accept_lang('de')) {
                            $lg=$_SESSION['lg']='de';
                        } else {
                            $lg=$_SESSION['lg']='de';
                        }
                }
                $this->lang->load('header',$lg);
                $this->lang->load('lien',$lg);
                $this->lang->load('container',$lg);
                $this->lang->load('footer',$lg);
                $this->lang->load('navigbar',$lg);
                $this->lang->load('tarifs',$lg);
                
                /*TRAITEMENT*/
                $donne_clinique ['pays'] = $this->uri->segment(3,0);
                $donne_clinique['ville'] = $this->uri->segment(4,0);
                $nom_url = $this->uri->segment(5,0);
                $id=$this->mod_fiche_clinique->translateNomUrlId($nom_url);
                if($id==0){ echo "clinique inexistante 1"."</br>";}
                else {
                    $donne_clinique['info'] = $this->mod_fiche_clinique->getInfoClinicId($id);
                    $donne_clinique['typetrait'] = $this->mod_fiche_clinique->getTypesTrait($id);
                    $donne_clinique['garanties'] = $this->mod_fiche_clinique->getGaranties($id);
                    $this->load->view('clinic/vue_traitement-tarif',$donne_clinique);
                }
            }
            
            function commentaire(){
                $lg=$_SESSION['lg'];
                    $this->lang->load('header',$lg);
                    $this->lang->load('lien',$lg);
                    $this->lang->load('container',$lg);
                    $this->lang->load('footer',$lg);
                    $this->load->view('clinic/vue_step_commentaire');
            }
}